<template>
    <el-dialog style="background-color: aquamarine;" :model-value="props.visible" :title="props.title" :width="props.width+'px'" :before-close="onClose">

        <!-- 内容显示区 -->
        <div class="container" :style="{height:height+'px'}">
            <slot name="content" style="width: 100%;"></slot>
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button type="danger" @click="onClose">取消</el-button>
                <el-button type="primary" @click="onConfirm">确认</el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script setup lang="ts">


//弹框的数据类型
interface DialogProps{
    title: string,
    visible: boolean,
    width: number,
    height:number
}

//接受父组件的数据(先设置默认值)
const props = withDefaults(defineProps<DialogProps>(), {
    title: '新增',
    visible: false,
    width: 630,
    height: 300
})
//注册事件
const emit=defineEmits(['onClose',"onConfirm"])
//弹框的关闭
const onClose = () => {
    emit('onClose');
}
const onConfirm = () => {
    emit('onConfirm');
}

</script>

<style lang="scss" scoped>
    .container{
        background-color: rgb(249, 252, 252);
        widows: 100%;
    }
</style>